package bdz.projects.atwww.electrolux.ui.core
{
	import bdz.common.events.DispatchChannel;
	import bdz.common.events.XMLLoaderEvent;
	import bdz.common.model.AppEnvironment;
	import bdz.common.model.XMLLoader;
	import bdz.projects.atwww.electrolux.controls.ELProgramRunner;
	import bdz.projects.atwww.electrolux.controls.ELUIController;
	import bdz.projects.atwww.electrolux.events.ELEvent;
	import bdz.projects.atwww.electrolux.model.ELModel;
	import bdz.projects.atwww.electrolux.ui.ELOptionsControl;
	import bdz.projects.atwww.electrolux.ui.ELPlayPauseControl;
	import bdz.projects.atwww.electrolux.ui.ELProgressControl;
	import bdz.projects.atwww.electrolux.ui.ELRotaryControl;
	
	import flash.display.MovieClip;
	import flash.events.Event;

	public class ELCoreView extends MovieClip {
		
		protected var dataModel:ELModel;
		protected var dataLoader:XMLLoader;
		protected var channel:DispatchChannel;
		protected var dataLocation:String;
		protected var env:AppEnvironment = AppEnvironment.getEnv();
		protected var controller:ELUIController;
		
		
		/* VIEWS */
		protected var _rotaryControl:ELRotaryControl;
		protected var _optionControl:ELOptionsControl;
		protected var _playPauseControl:ELPlayPauseControl;
		protected var _progressControl:ELProgressControl;
		protected var _programRunner:ELProgramRunner;
		
		
		public function ELCoreView(ar:AbstractRestriction) {
			super();
			addEventListener(Event.ADDED_TO_STAGE, initializeComponent);
		}
		protected function initializeComponent(evt:Event = null):void{
			controller = new ELUIController();
			
			dataModel = ELModel.getInstance();
			dataModel.addEventListener(ELEvent.PROGRAMS_PARSE_COMPLETE, onProgramsParseComplete);
			dataLoader = new XMLLoader("onDataLoaded");
			dataLoader.addEventListener("onDataLoaded", onDataLoaded);
			dataLoader.location = dataLocation;
			env.addSetting("application", this);
			dataLoader.send();
			
			
		}
		protected function initializeViews():void{
			
		} 
		private function onProgramsParseComplete(evt:ELEvent):void{
			
			initializeViews();
		}
		protected function onDataLoaded(evt:XMLLoaderEvent):void {
			dataModel.parseConfiguration(new XML(evt.data));
		}
		protected function getAbstract(datalocation:String):AbstractRestriction{
			dataLocation = datalocation;
			return new AbstractRestriction();
		}
		
		 
		
	}
}
internal class AbstractRestriction {}